package org.platform.core.filecommand.impl;

import com.mc.mic.core.tool.helper.SpringContextHelper;
import lombok.extern.slf4j.Slf4j;
import org.platform.core.filecommand.IFileCommand;
import org.platform.processor.task.TaskDiagnoseProcessor;
import org.platform.tool.helper.LogHelper;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 用于处理:    3.16.2 任务归档完成通知（文件）
 *
 * @author FengJie
 * @date 2018/8/22
 */
@Slf4j
public class TaskCatalogFileCommand implements IFileCommand {
    @Autowired
    private LogHelper logHelper;
    @Autowired
    private TaskDiagnoseProcessor processor;

    public TaskCatalogFileCommand() {
        if (null == logHelper) {
            logHelper = SpringContextHelper.getBean(LogHelper.class);
        }
        if (null == processor) {
            processor = SpringContextHelper.getBean(TaskDiagnoseProcessor.class);
        }
    }

    @Override
    public boolean doCommandAck(String filePath, String fileName, String txtMsg) {
        String operation = "接收到任务归档完成通知,正在执行: 诊断项检查流程";
        logHelper.normal(operation, null, null);
        log.info(operation);
        processor.addTaskDiagnose(fileName, txtMsg);
        return true;
    }
}
